﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.SharePoint;

namespace SPVSX.Common.Extensions
{
    /// <summary>
    /// Extensions to the ISharePointProjectItem object
    /// </summary>
    public static class ISharePointProjectExtensions
    {
        /// <summary>
        /// Get the items within the SharePoint project
        /// </summary>
        /// <param name="project">The ISharePointProject project object</param>
        /// <param name="projectItemTypeId">The item type id</param>
        /// <returns>The project items matching the supplied id</returns>
        public static IEnumerable<ISharePointProjectItem> GetItems(this ISharePointProject project, string projectItemTypeId)
        {
            return Enumerable.Where<ISharePointProjectItem>(project.ProjectItems, delegate(ISharePointProjectItem item)
            {
                return item.ProjectItemType.Id == projectItemTypeId;
            });
        }
    }
}
